home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / system-config-printer / cupspk.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-10-28  |  20KB  |  630 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import sys
  6. import tempfile
  7. import cups
  8. import dbus
  9. import gtk
  10. from debug import debugprint
  11. from dbus.mainloop.glib import DBusGMainLoop
  12. DBusGMainLoop(set_as_default = True)
  13. PK_AUTH_NAME = 'org.freedesktop.PolicyKit.AuthenticationAgent'
  14. PK_AUTH_PATH = '/org/gnome/PolicyKit/Manager'
  15. PK_AUTH_IFACE = 'org.freedesktop.PolicyKit.AuthenticationAgent'
  16. CUPS_PK_NAME = 'org.opensuse.CupsPkHelper.Mechanism'
  17. CUPS_PK_PATH = '/'
  18. CUPS_PK_IFACE = 'org.opensuse.CupsPkHelper.Mechanism'
  19. CUPS_PK_NEED_AUTH = 'org.opensuse.CupsPkHelper.Mechanism.NotPrivileged'
  20. pk_auth_ret = False
  21. pk_auth_error = None
  22. pk_auth_running = False
  23. pk_auth_done = False
  24.  
  25. def _pk_auth_reply_handler(ret):
  26.     global pk_auth_ret, pk_auth_done
  27.     pk_auth_ret = ret
  28.     pk_auth_done = True
  29.  
  30.  
  31. def _pk_auth_error_handler(e):
  32.     global pk_auth_error, pk_auth_done
  33.     pk_auth_error = str(e)
  34.     pk_auth_done = True
  35.  
  36.  
  37. class Connection:
  38.     
  39.     def __init__(self, host, port, encryption):
  40.         self._parent = None
  41.         
  42.         try:
  43.             self._session_bus = dbus.SessionBus()
  44.             self._system_bus = dbus.SystemBus()
  45.         except dbus.exceptions.DBusException:
  46.             self._session_bus = None
  47.             self._system_bus = None
  48.  
  49.         self._connection = cups.Connection(host = host, port = port, encryption = encryption)
  50.         self._hack_subclass()
  51.  
  52.     
  53.     def _hack_subclass(self):
  54.         methodtype = type(self._connection.getPrinters)
  55.         for fname in dir(self._connection):
  56.             if fname[0] == '_':
  57.                 continue
  58.             
  59.             fn = getattr(self._connection, fname)
  60.             if type(fn) != methodtype:
  61.                 continue
  62.             
  63.             if not hasattr(self, fname):
  64.                 setattr(self, fname, fn.__call__)
  65.                 continue
  66.         
  67.  
  68.     
  69.     def set_parent(self, parent):
  70.         self._parent = parent
  71.  
  72.     
  73.     def _get_cups_pk(self):
  74.         
  75.         try:
  76.             object = self._system_bus.get_object(CUPS_PK_NAME, CUPS_PK_PATH)
  77.             return dbus.Interface(object, CUPS_PK_IFACE)
  78.         except dbus.exceptions.DBusException:
  79.             return None
  80.             except AttributeError:
  81.                 return None
  82.             else:
  83.                 return None
  84.  
  85.  
  86.     
  87.     def _obtain_auth(self, action, xid = 0):
  88.         global pk_auth_ret, pk_auth_error, pk_auth_done, pk_auth_running
  89.         if pk_auth_running:
  90.             return False
  91.         pk_auth_ret = False
  92.         pk_auth_error = None
  93.         pk_auth_done = False
  94.         pk_auth_object = self._session_bus.get_object(PK_AUTH_NAME, PK_AUTH_PATH)
  95.         pk_auth = dbus.Interface(pk_auth_object, PK_AUTH_IFACE)
  96.         pk_auth_running = True
  97.         pk_auth.ObtainAuthorization(action, dbus.UInt32(xid), dbus.UInt32(os.getpid()), reply_handler = _pk_auth_reply_handler, error_handler = _pk_auth_error_handler, timeout = 0x80000000L / 1000)
  98.         while not pk_auth_done:
  99.             gtk.main_iteration(True)
  100.             continue
  101.             pk_auth_running
  102.         pk_auth_running = False
  103.         if pk_auth_error != None:
  104.             if pk_auth_error.find('org.freedesktop.DBus.Error.NoReply') == 0:
  105.                 return False
  106.             raise dbus.exceptions.DBusException(pk_auth_error)
  107.         pk_auth_error != None
  108.         if not type(pk_auth_ret) == dbus.Boolean:
  109.             return False
  110.         return pk_auth_ret != 0
  111.  
  112.     
  113.     def _handle_exception_with_auth(self, e):
  114.         if e.get_dbus_name() != CUPS_PK_NEED_AUTH:
  115.             return False
  116.         tokens = e.get_dbus_message().split(' ', 2)
  117.         if len(tokens) != 3:
  118.             return False
  119.         
  120.         try:
  121.             xid = 0
  122.             ret = self._obtain_auth(tokens[0], xid)
  123.         except dbus.exceptions.DBusException:
  124.             len(tokens) != 3
  125.             len(tokens) != 3
  126.             e.get_dbus_name() != CUPS_PK_NEED_AUTH
  127.             return False
  128.  
  129.         if not ret:
  130.             raise cups.IPPError(cups.IPP_NOT_AUTHORIZED, 'pkcancel')
  131.         ret
  132.         return True
  133.  
  134.     
  135.     def _call_with_pk_and_fallback(self, use_fallback, pk_function_name, pk_args, fallback_function, *args, **kwds):
  136.         pk_function = None
  137.         if not use_fallback:
  138.             cups_pk = self._get_cups_pk()
  139.             if cups_pk:
  140.                 
  141.                 try:
  142.                     pk_function = cups_pk.get_dbus_method(pk_function_name)
  143.                 except dbus.exceptions.DBusException:
  144.                     pass
  145.                 except:
  146.                     None<EXCEPTION MATCH>dbus.exceptions.DBusException
  147.                 
  148.  
  149.             None<EXCEPTION MATCH>dbus.exceptions.DBusException
  150.         
  151.         if use_fallback or not pk_function:
  152.             return fallback_function(*args, **kwds)
  153.         pk_retval = 'PolicyKit communication issue'
  154.         while True:
  155.             
  156.             try:
  157.                 pk_retval = pk_function(*pk_args)
  158.                 if type(pk_retval) == tuple:
  159.                     retval = pk_retval[1:]
  160.                     if pk_retval[0] == '':
  161.                         if len(retval) == 1:
  162.                             return retval[0]
  163.                         return retval
  164.                     pk_retval[0] == ''
  165.                 
  166.             continue
  167.             except dbus.exceptions.DBusException:
  168.                 not pk_function
  169.                 e = not pk_function
  170.                 if not self._handle_exception_with_auth(e):
  171.                     break
  172.                 
  173.                 self._handle_exception_with_auth(e)
  174.             
  175.  
  176.             not pk_function<EXCEPTION MATCH>dbus.exceptions.DBusException
  177.         if pk_retval != '':
  178.             debugprint('PolicyKit call to %s did not work: %s' % (pk_function_name, pk_retval))
  179.             return fallback_function(*args, **kwds)
  180.  
  181.     
  182.     def _args_to_tuple(self, types, *args):
  183.         retval = [
  184.             False]
  185.         if len(types) != len(args):
  186.             retval[0] = True
  187.             retval.extend(types)
  188.             return tuple(types)
  189.         exception = False
  190.         for i in range(len(types)):
  191.             if type(args[i]) != types[i]:
  192.                 if types[i] == str and type(args[i]) == unicode:
  193.                     pass
  194.                 elif types[i] == str and type(args[i]) == int:
  195.                     retval.append(str(args[i]))
  196.                     continue
  197.                 elif types[i] == str and type(args[i]) == float:
  198.                     retval.append(str(args[i]))
  199.                     continue
  200.                 elif types[i] == str and type(args[i]) == bool:
  201.                     retval.append(str(args[i]))
  202.                     continue
  203.                 elif types[i] == str and args[i] == None:
  204.                     retval.append('')
  205.                     continue
  206.                 elif types[i] == list and type(args[i]) == tuple:
  207.                     retval.append(list(args[i]))
  208.                     continue
  209.                 elif types[i] == list and args[i] == None:
  210.                     retval.append([])
  211.                     continue
  212.                 else:
  213.                     exception = True
  214.             
  215.             retval.append(args[i])
  216.         
  217.         retval[0] = exception
  218.         return tuple(retval)
  219.  
  220.     
  221.     def _kwds_to_vars(self, names, **kwds):
  222.         ret = []
  223.         for name in names:
  224.             if kwds.has_key(name):
  225.                 ret.append(kwds[name])
  226.                 continue
  227.             ret.append('')
  228.         
  229.         return tuple(ret)
  230.  
  231.     
  232.     def getDevices(self, *args, **kwds):
  233.         use_pycups = False
  234.         timeout = 0
  235.         include_schemes = ''
  236.         exclude_schemes = ''
  237.         if len(args) == 3:
  238.             (use_pycups, timeout, include_schemes, exclude_schemes) = self._args_to_tuple([
  239.                 int,
  240.                 str,
  241.                 str], *args)
  242.         elif kwds.has_key('timeout'):
  243.             timeout = kwds['timeout']
  244.         
  245.         if kwds.has_key('include_schemes'):
  246.             include_schemes = kwds['include_schemes']
  247.         
  248.         if kwds.has_key('exclude_schemes'):
  249.             exclude_schemes = kwds['exclude_schemes']
  250.         
  251.         pk_args = (timeout, include_schemes, exclude_schemes)
  252.         result = self._call_with_pk_and_fallback(use_pycups, 'DevicesGet', pk_args, self._connection.getDevices, *args, **kwds)
  253.         if len(result.keys()) > 0 and type(result[result.keys()[0]]) == dict:
  254.             return result
  255.         result_str = { }
  256.         if result != None:
  257.             for i in result.keys():
  258.                 if type(i) == dbus.String:
  259.                     result_str[str(i)] = str(result[i])
  260.                     continue
  261.                 type(result[result.keys()[0]]) == dict
  262.                 result_str[i] = result[i]
  263.             
  264.         
  265.         devices = { }
  266.         n = 0
  267.         postfix = ':' + str(n)
  268.         device_keys = _[1]
  269.         for x in result_str.keys():
  270.             if x.endswith(postfix):
  271.                 continue
  272.             _[2][x]
  273.             continue
  274.             device_keys = _[2]
  275.             continue
  276.             []
  277.         return devices
  278.  
  279.     
  280.     def cancelJob(self, *args, **kwds):
  281.         (use_pycups, jobid) = self._args_to_tuple([
  282.             int], *args)
  283.         pk_args = (jobid,)
  284.         self._call_with_pk_and_fallback(use_pycups, 'JobCancel', pk_args, self._connection.cancelJob, *args, **kwds)
  285.  
  286.     
  287.     def setJobHoldUntil(self, *args, **kwds):
  288.         (use_pycups, jobid, job_hold_until) = self._args_to_tuple([
  289.             int,
  290.             str], *args)
  291.         pk_args = (jobid, job_hold_until)
  292.         self._call_with_pk_and_fallback(use_pycups, 'JobSetHoldUntil', pk_args, self._connection.setJobHoldUntil, *args, **kwds)
  293.  
  294.     
  295.     def restartJob(self, *args, **kwds):
  296.         (use_pycups, jobid) = self._args_to_tuple([
  297.             int], *args)
  298.         pk_args = (jobid,)
  299.         self._call_with_pk_and_fallback(use_pycups, 'JobRestart', pk_args, self._connection.restartJob, *args, **kwds)
  300.  
  301.     
  302.     def getFile(self, *args, **kwds):
  303.         """ Keeping this as an alternative for the code.
  304.             We don't use it because it's not possible to know if the call was a
  305.             PK-one (and so we push the content of a temporary filename to fd or
  306.             file) or a non-PK-one (in which case nothing should be done).
  307.  
  308.                 filename = None
  309.                 fd = None
  310.                 file = None
  311.                 if use_pycups:
  312.                     if len(kwds) != 1:
  313.                         use_pycups = True
  314.                     elif kwds.has_key('filename'):
  315.                         filename = kwds['filename']
  316.                     elif kwds.has_key('fd'):
  317.                         fd = kwds['fd']
  318.                     elif kwds.has_key('file'):
  319.                         file = kwds['file']
  320.                     else:
  321.                         use_pycups = True
  322.  
  323.                     if fd or file:
  324.         """
  325.         file_object = None
  326.         fd = None
  327.         if len(args) == 2:
  328.             (use_pycups, resource, filename) = self._args_to_tuple([
  329.                 str,
  330.                 str], *args)
  331.         else:
  332.             (use_pycups, resource) = self._args_to_tuple([
  333.                 str], *args)
  334.             if kwds.has_key('filename'):
  335.                 filename = kwds['filename']
  336.             elif kwds.has_key('fd'):
  337.                 fd = kwds['fd']
  338.             elif kwds.has_key('file'):
  339.                 file_object = kwds['file']
  340.             elif not use_pycups:
  341.                 raise TypeError()
  342.             else:
  343.                 filename = None
  344.         if not use_pycups:
  345.             if fd != None or file_object != None:
  346.                 (tmpfd, tmpfname) = tempfile.mkstemp()
  347.                 os.close(tmpfd)
  348.                 pk_args = (resource, tmpfname)
  349.                 self._call_with_pk_and_fallback(use_pycups, 'FileGet', pk_args, self._connection.getFile, *args, **kwds)
  350.                 tmpfd = os.open(tmpfname, os.O_RDONLY)
  351.                 tmpfile = os.fdopen(tmpfd, 'r')
  352.                 tmpfile.seek(0)
  353.                 if fd != None:
  354.                     os.lseek(fd, 0, os.SEEK_SET)
  355.                     line = tmpfile.readline()
  356.                     while line != '':
  357.                         os.write(fd, line)
  358.                         line = tmpfile.readline()
  359.                 else:
  360.                     file_object.seek(0)
  361.                     line = tmpfile.readline()
  362.                     while line != '':
  363.                         file_object.write(line)
  364.                         line = tmpfile.readline()
  365.                 tmpfile.close()
  366.                 os.remove(tmpfname)
  367.             else:
  368.                 pk_args = (resource, filename)
  369.                 self._call_with_pk_and_fallback(use_pycups, 'FileGet', pk_args, self._connection.getFile, *args, **kwds)
  370.  
  371.     
  372.     def putFile(self, *args, **kwds):
  373.         if len(args) == 2:
  374.             (use_pycups, resource, filename) = self._args_to_tuple([
  375.                 str,
  376.                 str], *args)
  377.         else:
  378.             (use_pycups, resource) = self._args_to_tuple([
  379.                 str], *args)
  380.             if kwds.has_key('filename'):
  381.                 filename = kwds['filename']
  382.             elif kwds.has_key('fd'):
  383.                 fd = kwds['fd']
  384.             elif kwds.has_key('file'):
  385.                 file_object = kwds['file']
  386.             elif not use_pycups:
  387.                 raise TypeError()
  388.             else:
  389.                 filename = None
  390.         if not use_pycups:
  391.             if fd != None or file_object != None:
  392.                 (tmpfd, tmpfname) = tempfile.mkstemp()
  393.                 os.lseek(tmpfd, 0, os.SEEK_SET)
  394.                 if fd != None:
  395.                     os.lseek(fd, 0, os.SEEK_SET)
  396.                     buf = os.read(fd, 512)
  397.                     while buf != '':
  398.                         os.write(tmpfd, buf)
  399.                         buf = os.read(fd, 512)
  400.                 else:
  401.                     file_object.seek(0)
  402.                     line = file_object.readline()
  403.                     while line != '':
  404.                         os.write(tmpfd, line)
  405.                         line = file_object.readline()
  406.                 os.close(tmpfd)
  407.                 pk_args = (resource, tmpfname)
  408.                 self._call_with_pk_and_fallback(use_pycups, 'FilePut', pk_args, self._connection.putFile, *args, **kwds)
  409.                 os.remove(tmpfname)
  410.             else:
  411.                 pk_args = (resource, filename)
  412.                 self._call_with_pk_and_fallback(use_pycups, 'FilePut', pk_args, self._connection.putFile, *args, **kwds)
  413.  
  414.     
  415.     def addPrinter(self, *args, **kwds):
  416.         (use_pycups, name) = self._args_to_tuple([
  417.             str], *args)
  418.         (filename, ppdname, info, location, device, ppd) = self._kwds_to_vars([
  419.             'filename',
  420.             'ppdname',
  421.             'info',
  422.             'location',
  423.             'device',
  424.             'ppd'], **kwds)
  425.         need_unlink = False
  426.         if not ppdname and not filename and ppd:
  427.             (fd, filename) = tempfile.mkstemp()
  428.             ppd.writeFd(fd)
  429.             os.close(fd)
  430.             need_unlink = True
  431.         
  432.         if filename and not ppdname:
  433.             pk_args = (name, device, filename, info, location)
  434.             self._call_with_pk_and_fallback(use_pycups, 'PrinterAddWithPpdFile', pk_args, self._connection.addPrinter, *args, **kwds)
  435.             if need_unlink:
  436.                 os.unlink(filename)
  437.             
  438.         else:
  439.             pk_args = (name, device, ppdname, info, location)
  440.             self._call_with_pk_and_fallback(use_pycups, 'PrinterAdd', pk_args, self._connection.addPrinter, *args, **kwds)
  441.  
  442.     
  443.     def setPrinterDevice(self, *args, **kwds):
  444.         (use_pycups, name, device) = self._args_to_tuple([
  445.             str,
  446.             str], *args)
  447.         pk_args = (name, device)
  448.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetDevice', pk_args, self._connection.setPrinterDevice, *args, **kwds)
  449.  
  450.     
  451.     def setPrinterInfo(self, *args, **kwds):
  452.         (use_pycups, name, info) = self._args_to_tuple([
  453.             str,
  454.             str], *args)
  455.         pk_args = (name, info)
  456.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetInfo', pk_args, self._connection.setPrinterInfo, *args, **kwds)
  457.  
  458.     
  459.     def setPrinterLocation(self, *args, **kwds):
  460.         (use_pycups, name, location) = self._args_to_tuple([
  461.             str,
  462.             str], *args)
  463.         pk_args = (name, location)
  464.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetLocation', pk_args, self._connection.setPrinterLocation, *args, **kwds)
  465.  
  466.     
  467.     def setPrinterShared(self, *args, **kwds):
  468.         (use_pycups, name, shared) = self._args_to_tuple([
  469.             str,
  470.             bool], *args)
  471.         pk_args = (name, shared)
  472.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetShared', pk_args, self._connection.setPrinterShared, *args, **kwds)
  473.  
  474.     
  475.     def setPrinterJobSheets(self, *args, **kwds):
  476.         (use_pycups, name, start, end) = self._args_to_tuple([
  477.             str,
  478.             str,
  479.             str], *args)
  480.         pk_args = (name, start, end)
  481.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetJobSheets', pk_args, self._connection.setPrinterJobSheets, *args, **kwds)
  482.  
  483.     
  484.     def setPrinterErrorPolicy(self, *args, **kwds):
  485.         (use_pycups, name, policy) = self._args_to_tuple([
  486.             str,
  487.             str], *args)
  488.         pk_args = (name, policy)
  489.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetErrorPolicy', pk_args, self._connection.setPrinterErrorPolicy, *args, **kwds)
  490.  
  491.     
  492.     def setPrinterOpPolicy(self, *args, **kwds):
  493.         (use_pycups, name, policy) = self._args_to_tuple([
  494.             str,
  495.             str], *args)
  496.         pk_args = (name, policy)
  497.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetOpPolicy', pk_args, self._connection.setPrinterOpPolicy, *args, **kwds)
  498.  
  499.     
  500.     def setPrinterUsersAllowed(self, *args, **kwds):
  501.         (use_pycups, name, users) = self._args_to_tuple([
  502.             str,
  503.             list], *args)
  504.         pk_args = (name, users)
  505.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetUsersAllowed', pk_args, self._connection.setPrinterUsersAllowed, *args, **kwds)
  506.  
  507.     
  508.     def setPrinterUsersDenied(self, *args, **kwds):
  509.         (use_pycups, name, users) = self._args_to_tuple([
  510.             str,
  511.             list], *args)
  512.         pk_args = (name, users)
  513.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetUsersDenied', pk_args, self._connection.setPrinterUsersDenied, *args, **kwds)
  514.  
  515.     
  516.     def addPrinterOptionDefault(self, *args, **kwds):
  517.         (use_pycups, name, option, value) = self._args_to_tuple([
  518.             str,
  519.             str,
  520.             str], *args)
  521.         if not use_pycups:
  522.             values = (value,)
  523.         else:
  524.             (use_pycups, name, option, values) = self._args_to_tuple([
  525.                 str,
  526.                 str,
  527.                 list], *args)
  528.         pk_args = (name, option, values)
  529.         self._call_with_pk_and_fallback(use_pycups, 'PrinterAddOptionDefault', pk_args, self._connection.addPrinterOptionDefault, *args, **kwds)
  530.  
  531.     
  532.     def deletePrinterOptionDefault(self, *args, **kwds):
  533.         (use_pycups, name, option) = self._args_to_tuple([
  534.             str,
  535.             str], *args)
  536.         pk_args = (name, option)
  537.         self._call_with_pk_and_fallback(use_pycups, 'PrinterDeleteOptionDefault', pk_args, self._connection.deletePrinterOptionDefault, *args, **kwds)
  538.  
  539.     
  540.     def deletePrinter(self, *args, **kwds):
  541.         (use_pycups, name) = self._args_to_tuple([
  542.             str], *args)
  543.         pk_args = (name,)
  544.         self._call_with_pk_and_fallback(use_pycups, 'PrinterDelete', pk_args, self._connection.deletePrinter, *args, **kwds)
  545.  
  546.     
  547.     def addPrinterToClass(self, *args, **kwds):
  548.         (use_pycups, printer, name) = self._args_to_tuple([
  549.             str,
  550.             str], *args)
  551.         pk_args = (name, printer)
  552.         self._call_with_pk_and_fallback(use_pycups, 'ClassAddPrinter', pk_args, self._connection.addPrinterToClass, *args, **kwds)
  553.  
  554.     
  555.     def deletePrinterFromClass(self, *args, **kwds):
  556.         (use_pycups, printer, name) = self._args_to_tuple([
  557.             str,
  558.             str], *args)
  559.         pk_args = (name, printer)
  560.         self._call_with_pk_and_fallback(use_pycups, 'ClassDeletePrinter', pk_args, self._connection.deletePrinterFromClass, *args, **kwds)
  561.  
  562.     
  563.     def deleteClass(self, *args, **kwds):
  564.         (use_pycups, name) = self._args_to_tuple([
  565.             str], *args)
  566.         pk_args = (name,)
  567.         self._call_with_pk_and_fallback(use_pycups, 'ClassDelete', pk_args, self._connection.deleteClass, *args, **kwds)
  568.  
  569.     
  570.     def setDefault(self, *args, **kwds):
  571.         (use_pycups, name) = self._args_to_tuple([
  572.             str], *args)
  573.         pk_args = (name,)
  574.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetDefault', pk_args, self._connection.setDefault, *args, **kwds)
  575.  
  576.     
  577.     def enablePrinter(self, *args, **kwds):
  578.         (use_pycups, name) = self._args_to_tuple([
  579.             str], *args)
  580.         pk_args = (name, True)
  581.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetEnabled', pk_args, self._connection.enablePrinter, *args, **kwds)
  582.  
  583.     
  584.     def disablePrinter(self, *args, **kwds):
  585.         (use_pycups, name) = self._args_to_tuple([
  586.             str], *args)
  587.         pk_args = (name, False)
  588.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetEnabled', pk_args, self._connection.disablePrinter, *args, **kwds)
  589.  
  590.     
  591.     def acceptJobs(self, *args, **kwds):
  592.         (use_pycups, name) = self._args_to_tuple([
  593.             str], *args)
  594.         pk_args = (name, True, '')
  595.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetAcceptJobs', pk_args, self._connection.acceptJobs, *args, **kwds)
  596.  
  597.     
  598.     def rejectJobs(self, *args, **kwds):
  599.         (use_pycups, name) = self._args_to_tuple([
  600.             str], *args)
  601.         (reason,) = self._kwds_to_vars([
  602.             'reason'], **kwds)
  603.         pk_args = (name, False, reason)
  604.         self._call_with_pk_and_fallback(use_pycups, 'PrinterSetAcceptJobs', pk_args, self._connection.rejectJobs, *args, **kwds)
  605.  
  606.     
  607.     def adminGetServerSettings(self, *args, **kwds):
  608.         use_pycups = False
  609.         pk_args = ()
  610.         result = self._call_with_pk_and_fallback(use_pycups, 'ServerGetSettings', pk_args, self._connection.adminGetServerSettings, *args, **kwds)
  611.         settings = { }
  612.         if result != None:
  613.             for i in result.keys():
  614.                 if type(i) == dbus.String:
  615.                     settings[str(i)] = str(result[i])
  616.                     continue
  617.                 settings[i] = result[i]
  618.             
  619.         
  620.         return settings
  621.  
  622.     
  623.     def adminSetServerSettings(self, *args, **kwds):
  624.         (use_pycups, settings) = self._args_to_tuple([
  625.             dict], *args)
  626.         pk_args = (settings,)
  627.         self._call_with_pk_and_fallback(use_pycups, 'ServerSetSettings', pk_args, self._connection.adminSetServerSettings, *args, **kwds)
  628.  
  629.  
  630.